# -*- coding: utf-8 -*-
'''
Cria servidor HTTP e abre a página automaticamente no browser
@author: Luís Fonte nº6043
Data de Criação: 03/12/2011
'''

import SimpleHTTPServer
import SocketServer
import threading
import webbrowser


class localHTTPServer:

    # Cria servidor no port 8130
    # Adaptado do exemplo dado na aula pelo professor
    PORT = 8130

    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    
    httpd = SocketServer.TCPServer(("", PORT), Handler)
    server_thread = threading.Thread(target=httpd.serve_forever)
    server_thread.setDaemon(True)
    server_thread.start()
    webbrowser.open("http://localhost:8120/index.html".encode('utf-8'))
    print "Serving at port", PORT
